Sync tooltips on toolitems.
authorMatthias Clasen <maclas@gmx.de>
Tue, 23 Sep 2003 23:42:39 +0000 (23:42 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 23 Sep 2003 23:42:39 +0000 (23:42 +0000)
2003-09-24  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.

* gtk/gtkuimanager.c (update_node): Don't complain about missing
actions on popups. Re-set "tooltip" property on toolitems after
adding them to parent to trigger proxy update.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkaction.c
gtk/gtkuimanager.c

index 935a6f64f0c6020499dcf72fb8e7b74767d01839..1d0fc9b9f500dd91fbf279c2111457915e0c3d98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-24  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.
+
+       * gtk/gtkuimanager.c (update_node): Don't complain about missing
+       actions on popups. Re-set "tooltip" property on toolitems after
+       adding them to parent to trigger proxy update.
+
 2003-09-22  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testmerge.c (main): Initially activate the JUSTIFY_RIGHT
index 935a6f64f0c6020499dcf72fb8e7b74767d01839..1d0fc9b9f500dd91fbf279c2111457915e0c3d98 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-24  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.
+
+       * gtk/gtkuimanager.c (update_node): Don't complain about missing
+       actions on popups. Re-set "tooltip" property on toolitems after
+       adding them to parent to trigger proxy update.
+
 2003-09-22  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testmerge.c (main): Initially activate the JUSTIFY_RIGHT
index 935a6f64f0c6020499dcf72fb8e7b74767d01839..1d0fc9b9f500dd91fbf279c2111457915e0c3d98 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-24  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.
+
+       * gtk/gtkuimanager.c (update_node): Don't complain about missing
+       actions on popups. Re-set "tooltip" property on toolitems after
+       adding them to parent to trigger proxy update.
+
 2003-09-22  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testmerge.c (main): Initially activate the JUSTIFY_RIGHT
index 935a6f64f0c6020499dcf72fb8e7b74767d01839..1d0fc9b9f500dd91fbf279c2111457915e0c3d98 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-24  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.
+
+       * gtk/gtkuimanager.c (update_node): Don't complain about missing
+       actions on popups. Re-set "tooltip" property on toolitems after
+       adding them to parent to trigger proxy update.
+
 2003-09-22  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testmerge.c (main): Initially activate the JUSTIFY_RIGHT
index 935a6f64f0c6020499dcf72fb8e7b74767d01839..1d0fc9b9f500dd91fbf279c2111457915e0c3d98 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-24  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.c (connect_proxy): Sync tooltips on toolitems.
+
+       * gtk/gtkuimanager.c (update_node): Don't complain about missing
+       actions on popups. Re-set "tooltip" property on toolitems after
+       adding them to parent to trigger proxy update.
+
 2003-09-22  Matthias Clasen  <maclas@gmx.de>
 
        * tests/testmerge.c (main): Initially activate the JUSTIFY_RIGHT
index e3ce12e8739442d98a4c39b660d8c481bcf6c9e1..38d986a7fbf33d3a91f5217ea18e1bf8b314ba7e 100644 (file)
 #include <config.h>
 
 #include "gtkaction.h"
+#include "gtkaccellabel.h"
 #include "gtkbutton.h"
-#include "gtktoolbutton.h"
-#include "gtkmenuitem.h"
-#include "gtkimagemenuitem.h"
-#include "gtkstock.h"
-#include "gtklabel.h"
 #include "gtkimage.h"
-#include "gtkaccellabel.h"
+#include "gtkimagemenuitem.h"
 #include "gtkintl.h"
+#include "gtklabel.h"
+#include "gtkmenuitem.h"
+#include "gtkstock.h"
+#include "gtktoolbutton.h"
+#include "gtktoolbar.h"
 
 
 #define GTK_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ACTION, GtkActionPrivate))
@@ -530,6 +531,25 @@ gtk_action_sync_stock_id (GtkAction  *action,
     }
 }
 
+static void
+gtk_action_sync_tooltip (GtkAction  *action, 
+                        GParamSpec *pspec, 
+                        GtkWidget  *proxy)
+{
+  g_return_if_fail (GTK_IS_TOOL_ITEM (proxy));
+
+  if (GTK_IS_TOOLBAR (gtk_widget_get_parent (proxy)))
+    {
+      GtkToolbar *toolbar = GTK_TOOLBAR (gtk_widget_get_parent (proxy));
+      
+      gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (proxy), 
+                                toolbar->tooltips,
+                                action->private_data->tooltip,
+                                NULL);
+    }
+}
+
+
 static gboolean
 gtk_action_create_menu_proxy (GtkToolItem *tool_item, 
                              GtkAction   *action)
@@ -648,6 +668,9 @@ connect_proxy (GtkAction     *action,
                    "stock_id", action->private_data->stock_id,
                    "is_important", action->private_data->is_important,
                    NULL);
+      /* FIXME: we should set the tooltip here, but the current api
+       * doesn't allow it before the item is added to a toolbar. 
+       */
       g_signal_connect_object (action, "notify::short_label",
                               G_CALLBACK (gtk_action_sync_short_label),
                               proxy, 0);      
@@ -657,6 +680,9 @@ connect_proxy (GtkAction     *action,
       g_signal_connect_object (action, "notify::is_important",
                               G_CALLBACK (gtk_action_sync_property), 
                               proxy, 0);
+      g_signal_connect_object (action, "notify::tooltip",
+                              G_CALLBACK (gtk_action_sync_tooltip), 
+                              proxy, 0);
 
       g_signal_connect_object (proxy, "create_menu_proxy",
                               G_CALLBACK (gtk_action_create_menu_proxy),
index bdb68279cc4e5782b9b8cf1b15c33de262323e7d..cb19d7e23171fa819f36a07f0bc84782799b46bd 100644 (file)
 #include <config.h>
 
 #include <string.h>
-#include "gtkuimanager.h"
-#include "gtktoolbar.h"
-#include "gtkseparatortoolitem.h"
-#include "gtkmenushell.h"
+#include "gtkintl.h"
+#include "gtkmarshalers.h"
 #include "gtkmenu.h"
 #include "gtkmenubar.h"
+#include "gtkmenushell.h"
 #include "gtkseparatormenuitem.h"
+#include "gtkseparatortoolitem.h"
 #include "gtktearoffmenuitem.h"
-#include "gtkintl.h"
+#include "gtktoolbar.h"
+#include "gtkuimanager.h"
 
 #undef DEBUG_UI_MANAGER
 
@@ -1723,6 +1724,7 @@ update_node (GtkUIManager *self,
   Node *info;
   GNode *child;
   GtkAction *action;
+  gchar *tooltip;
 #ifdef DEBUG_UI_MANAGER
   GList *tmp;
 #endif
@@ -1767,6 +1769,7 @@ update_node (GtkUIManager *self,
          info->type != NODE_TYPE_ROOT &&
          info->type != NODE_TYPE_MENUBAR &&
          info->type != NODE_TYPE_TOOLBAR &&
+         info->type != NODE_TYPE_POPUP &&
          info->type != NODE_TYPE_SEPARATOR &&
          info->type != NODE_TYPE_MENU_PLACEHOLDER &&
          info->type != NODE_TYPE_TOOLBAR_PLACEHOLDER)
@@ -1984,7 +1987,7 @@ update_node (GtkUIManager *self,
              if (find_menu_position (node, &menushell, &pos))
                {
                  info->proxy = gtk_action_create_menu_item (action);
-
+                 
                  gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
                                         info->proxy, pos);
                }
@@ -2024,7 +2027,13 @@ update_node (GtkUIManager *self,
                  info->proxy = gtk_action_create_tool_item (action);
 
                  gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
-                                               GTK_TOOL_ITEM (info->proxy), pos);
+                                     GTK_TOOL_ITEM (info->proxy), pos);
+
+                 /* FIXME: this is necessary, since tooltips on toolitems
+                  * can't be set before the toolitem is added to the toolbar.
+                  */
+                 g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
+                 g_object_set (G_OBJECT (action), "tooltip", tooltip, NULL);
                }
            }
          else
@@ -2033,6 +2042,7 @@ update_node (GtkUIManager *self,
                                                    G_CALLBACK (update_smart_separators),
                                                    0);
              gtk_action_connect_proxy (action, info->proxy);
+
            }
          g_signal_connect (info->proxy, "notify::visible",
                            G_CALLBACK (update_smart_separators), 0);
@@ -2222,11 +2232,11 @@ static const gchar *open_tag_format[] = {
   "%*s<UNDECIDED>\n",
   "%*s<ui>\n",
   "%*s<menubar name=\"%s\">\n",  
-  "%*s<menu name='%s' action=\"%s\">\n",
+  "%*s<menu name=\"%s\" action=\"%s\">\n",
   "%*s<toolbar name=\"%s\">\n",
   "%*s<placeholder name=\"%s\">\n",
   "%*s<placeholder name=\"%s\">\n",
-  "%*s<popup name='%s' action=\"%s\">\n",
+  "%*s<popup name=\"%s\">\n",
   "%*s<menuitem name=\"%s\" action=\"%s\"/>\n", 
   "%*s<toolitem name=\"%s\" action=\"%s\"/>\n", 
   "%*s<separator name=\"%s\"/>\n",